
#pragma once
#include "movie.h"
#include "Movieregister.h"
#include <string>
#include <clocale>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <algorithm>
#include <memory>
using namespace std;


class MovieDatabase : public vector<Movieregister>
{
public:

	MovieDatabase()
	{
	}
	void ReadFromFilesToDatabase()
	{
		this->clear(); 

		string str, strRow;
		ifstream fin("db.txt");

		while (std::getline(fin, strRow))
		{
			Movieregister mr;
			mr.ReadFromFile(strRow);
			if (mr.GetName().compare("") != 0) 
			{
				this->push_back(mr);
			}
		}
	}

	string List()
	{
		string s = "";
		for (auto &item : *this)
		{
			s += "\n" +  item.GetName() + "\n";
			//s += item.list();//
		}
		return s;
	}

	string SearchTitle(string keyword)
	{
 		string s = "";

		for (auto &item : *this)
		{
			s += item.SearchTitle(keyword);
		}

		return s;
	}






	~MovieDatabase()
	{
	}
};

